package org.jader.bolao.gui.swing.table;

import java.util.List;

import org.jader.bolao.GamePlayer;
import org.jader.bolao.GameTeamed;
import org.jader.bolao.Team;

public class GameTeamedPlayersTableModel extends GamePlayersTableModel {
	private static final long serialVersionUID = 1L;
	
	private GameTeamed game = null;
	private Team team = null;
	
	public GameTeamedPlayersTableModel(GameTeamed game, Team team) {
		super();
		this.game = game;
		this.team = team;
	}
	
	@Override
	public GamePlayer getPlayerByRow(int row) {
		List<GamePlayer> teamPlayers = game.subListOfPlayers(team);
		if (row >= teamPlayers.size()) return null;
		return (GamePlayer) teamPlayers.get(row);
	}

	@Override
	protected COLUMNS getColumnByNumber(int col) {
		COLUMNS cols = null;
		switch(col) {
		case 0:
			cols = COLUMNS.POSITION;
			break;
		case 1:
			cols = COLUMNS.PLAYER;
			break;
		case 2:
			cols = COLUMNS.POINTS;
			break;
		case 3:
			cols = COLUMNS.DETAILED;
			break;
		case 4:
			cols = COLUMNS.SUMMED;
			break;
		}
		return cols;
	}

	@Override
	public int getRowCount() {
    	if (game == null || team == null) return 0;
    	return game.subListOfPlayers(team).size();
    }
    
	@Override
	public int getColumnCount() {
    	return 5;
    }
}
